package com.aqgj.Role.bean;

import javax.persistence.*;

import com.aqgj.User.bean.User;
import com.aqgj.util.BaseEntity;
import com.fasterxml.jackson.annotation.JsonBackReference;
import org.hibernate.annotations.GenericGenerator;

import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "role")
public class Role implements BaseEntity {

    private String id;//ä¸»é”®id

    private String name;//角色名

    private Integer seq;//排序号

    private String description;//简介

    private Integer status;//状态

    private Set<User> users = new HashSet<User>();

    public void setId(String value){
        this.id = value;
    }
    public void setName(String value){
        this.name = value;
    }
    public void setSeq(Integer value){
        this.seq = value;
    }
    public void setDescription(String value){
        this.description = value;
    }
    public void setStatus(Integer value){
        this.status = value;
    }

    public void setUsers(Set<User> users) {
        this.users = users;
    }

    @Id
    @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @Column(name ="id",unique=true,nullable=false,insertable=true,updatable=true,length=32)
    public String getId(){
        return this.id;
    }
    @Column(name ="name",unique=false,nullable=false,insertable=true,updatable=true,length=64)
    public String getName(){
        return this.name;
    }
    @Column(name ="seq",unique=false,nullable=false,insertable=true,updatable=true,length=3)
    public Integer getSeq(){
        return this.seq;
    }
    @Column(name ="description",unique=false,nullable=true,insertable=true,updatable=true,length=255)
    public String getDescription(){
        return this.description;
    }
    @Column(name ="status",unique=false,nullable=false,insertable=true,updatable=true,length=3)
    public Integer getStatus(){
        return this.status;
    }

    @JsonBackReference
    @ManyToMany(mappedBy="roles")
    public Set<User> getUsers() {
        return users;
    }
}
